package com.cndongtai.vo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PageForm<T> {
	
	private int nowPage = 1;
	
	private int totalSize = 0;
	
	private int pageSize = 15;// 默认20分页
	
	private Map<String,Object> conditionMap = new HashMap<String,Object>();
	
	private List<T> dataList;
	
	public void addCondition(String key, Object value) {
		conditionMap.put(key, value);
	}
	
	public Object getCondition(String key) {
		return conditionMap.get(key);
	}

	public Map<String, Object> getConditionMap() {
		// 计算分页
		int startNum = nowPage>1?((nowPage-1)*pageSize):0;
		conditionMap.put("startNum", startNum);
		conditionMap.put("pageSize", pageSize);
		
		return conditionMap;
	}

	public void setConditionMap(Map<String, Object> conditionMap) {
		this.conditionMap = conditionMap;
	}

	public int getNowPage() {
		return nowPage;
	}

	public void setNowPage(int nowPage) {
		this.nowPage = nowPage;
	}

	public int getTotalSize() {
		return totalSize;
	}

	public void setTotalSize(int totalSize) {
		this.totalSize = totalSize;
		if(this.totalSize==0) {
			this.nowPage = 1;
		}
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public List<T> getDataList() {
		return dataList;
	}

	public void setDataList(List<T> dataList) {
		this.dataList = dataList;
	}

}
